<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('对接学生')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <p>弹出可供选择教师列表（点击确定后得到数据）</p>
            <button id="choose" type="button" class="btn btn-primary" onclick="selectCheckUser()">选择导师</button>
        </div>
        <div class="col-sm-12 select-table table-striped" style="min-height: 15%;">
            <h5>确认已双选教师</h5>
            <table id="bootstrap-table1"></table>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <h5>已选教师</h5>
            <table id="bootstrap-table"></table>
        </div>

    </div>
</div>
<th:block th:include="include :: footer" />


<script th:inline="javascript">
    var teaSexDatas = [[${@dict.getType('sys_user_sex')}]];
    var prefix1 = ctx + "system/tea";
    $(function() {
        var options1 = {
            id: "bootstrap-table1",
            url: prefix1 + "/confirm",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            columns: [
                {
                    field: 'teaJno',
                    title: '工号'
                },
                {
                    field: 'teaName',
                    title: '姓名'
                },
                {
                    field: 'teaSex',
                    title: '性别',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(teaSexDatas, value);
                    }
                },
                {
                    field: 'teaPhone',
                    title: '电话'
                },
                {
                    field: 'teaSkill',
                    title: '特长'
                },
                {
                    field: 'teaTitle',
                    title: '职称'
                }]
        };
        $.table.init(options1);


        var options = {
            url: prefix1 + "/chooseList",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            columns: [
                {
                    field: 'teaJno',
                    title: '工号'
                },
                {
                    field: 'teaName',
                    title: '姓名'
                },
                {
                    field: 'teaSex',
                    title: '性别',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(teaSexDatas, value);
                    }
                },
                {
                    field: 'teaPhone',
                    title: '电话'
                },
                {
                    field: 'teaSkill',
                    title: '特长'
                },
                {
                    field: 'teaTitle',
                    title: '职称'
                }]
        };
        $.table.init(options);

    });
</script>

<script type="text/javascript">
    var prefix = ctx + "system/tutor";

    function selectCheckUser(){
        //判断第一个表里有没有数据
        var lie1 = $("#bootstrap-table1").find("tr").find("td").length;

        //判断第二个表里有没有数据
        var lie2 = $("#bootstrap-table").find("tr").find("td").length;
        //判断第二个表里数据是否为2
        var rows = $('#bootstrap-table').find("tr").length;

        if(lie1!=1||rows==3){
            alert("无可选择")
        }else  if(lie1==1 && rows==2&& lie2!=1 ){
            $.modal.openTab("选择导师", prefix + "/chooseOne");
        }else  if(lie1==1 && rows==2&& lie2==1 ){
            $.modal.openTab("选择导师", prefix + "/chooseTwo");
        }
    }
</script>


</body>
</html>

